﻿Imports System.Web.Services
Imports System.Web.Script.Services

Partial Class ajax
    Inherits System.Web.UI.Page
    <WebMethod()> _
    <ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
    Public Shared Function loadContinuesListHotels(ByVal page As Integer, ByVal id_city As String) As List(Of String)
        Dim result As String = ""
        Dim idTinhThanh As New Guid(id_city)
        Dim nCountAll As Integer = KhachSanServer.GetCountKhachSanByIDTinhThanh(idTinhThanh)

        Dim listKhachSan As List(Of KhachSan) = KhachSanServer.GetListKhachSanByIDTinhThanh(idTinhThanh, page)
        For i As Integer = 0 To listKhachSan.Count - 1
            Dim ks As KhachSan = listKhachSan(i)
            Dim urlImage As String = String.Format("http://www.khachsan24gio.vn{0}", ks.IMG_URL)
            Dim item As String = ""
            Dim urlDetail As String = String.Format("DetailKhachSan.aspx?IDKS={0}", ks.ID)
            item = String.Format("{0} <div style ='padding :10px;'> <div style ='float: left; padding-right: 10px;'> ", item)
            item = String.Format("{0} <a style ='text-decoration:none; width: 80px; height: 80px; display: block'  data-ajax='false'  href ='{1}' > ", item, urlDetail)
            item = String.Format("{0} <img width='80' height='80' alt='{1}' src='{2}' /> </a></div> ", item, ks.NAME, urlImage)
            item = String.Format("{0}  <div style =' color: #6B6B6B;font-size: 0.8em;'><div style ='color: #097AC8; font-size: 1.1em; font-weight: bold;'> ", item)
            'item = String.Format("{0}             <rewrites>  <add name= 'rewrite' virtualUrl= '^~/kien-thuc-seo/rewrite-url-asp-net.html' rewriteUrlParameter=  'ExcludeFromClientQueryString' destinationUrl= '~/product.aspx?cate_id=1&product_id=10' ignoreCase= 'true'/> </rewrites>")
            item = String.Format("{0} <a class=""ui-link"" style='text-decoration:none;'  data-ajax='false' href='{1}' > {2}</a> </div> ", item, urlDetail, ks.NAME)
            Dim strGia As String = ""
            If ks.HIENTHIGIA = True AndAlso ks.GIA > 0 Then
                strGia = Format(ks.GIA, "#,###")
            Else
                strGia = String.Format("<a class=""ui-link"" data-ajax='false' style=""text-decoration:none;"" href=""GetPrice.aspx?IDKS={0}"">Click lấy giá</a>", ks.ID)

            End If
            item = String.Format("{0} <div style ='color: #FFA500; float: right; font-size: 1.1em; font-weight: bold;'>{1}  </div>", item, strGia)
            Dim strStart As String = String.Format("Images/star-yellow-{0}-0.png", ks.STARS)

            item = String.Format("{0}  <div style =''><img  src='{1}'> </div> <div style =''> <img style='float: left;padding-right: 5px;' src='Images/hand.png' alt=''>", item, strStart)
            item = String.Format("{0} <div style ='padding-top: 2px;'>{1} đánh giá</div></div></div>", item, ks.COUNTDANHGIA)
            item = String.Format("{0} <div style ='clear :both ;'></div></div>", item)
            item = String.Format("{0} <div style ='background: none repeat scroll 0 0 #D1D1D1; height: 2px;'></div>", item)

            ''String.Format("<div style ='padding:10px;'><div id='{0}' style='cursor:pointer;' onclick='SelectedKhachSan(this)'>Khách sạn {1}</div></div>", listKhachSan(i).ID, listKhachSan(i).NAME)

            result += item
        Next
        Dim list As List(Of String) = New List(Of String)
        list.Add(result)
        If Util.GetConfigKey("page_num") * (page + 1) > nCountAll Or Util.GetConfigKey("page_num") * (page + 1) = nCountAll Then
            list.Add("1")
        Else
            list.Add("0")
        End If
        Return list
    End Function
    <WebMethod()> _
   <ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
    Public Shared Function loadContinuesListHotelsAdd(ByVal page As String, ByVal id_city As String, ByVal json_start As String, ByVal json_price As String, ByVal dangKM As Integer, ByVal optionSX As Integer, ByVal nameSearch As String) As List(Of String)
        Dim result As String = ""
        Dim idTinhThanh As New Guid(id_city)
        Dim arrStart As New ArrayList
        Dim arrGia As New ArrayList
        Dim arr_json_start As ArrayList = JsonTools.JsonToObject(json_start)
        Dim arr_json_price As ArrayList = JsonTools.JsonToObject(json_price)
        If arr_json_start.Item(0) = 1 Then
            arrStart.Add(1)
        End If
        If arr_json_start.Item(1) = 1 Then
            arrStart.Add(2)
        End If
        If arr_json_start.Item(2) = 1 Then
            arrStart.Add(3)
        End If
        If arr_json_start.Item(3) = 1 Then
            arrStart.Add(4)
        End If
        If arr_json_start.Item(4) = 1 = True Then
            arrStart.Add(5)
        End If

        If arr_json_price.Item(0) = 1 Then
            arrGia.Add("<500000 and 0<")
        End If
        If arr_json_price.Item(1) = 1 Then
            arrGia.Add("<=1000000 and 500000<=")
        End If
        If arr_json_price.Item(2) = 1 Then
            arrGia.Add("<=2000000 and 1000000<=")
        End If
        If arr_json_price.Item(3) = 1 Then
            arrGia.Add("<=5000000 and 2000000<=")
        End If
        If arr_json_price.Item(4) = 1 Then
            arrGia.Add("<=5000000 or 5000000>")
        End If
        Dim nCountAll As Integer = KhachSanServer.SearchNangCaoCountListKhachSanByIDTinhThanh(idTinhThanh, dangKM, arrStart, arrGia, optionSX, page, nameSearch)

        Dim listKhachSan As List(Of KhachSan) = KhachSanServer.SearchNangCaoListKhachSanByIDTinhThanh(idTinhThanh, dangKM, arrStart, arrGia, optionSX, page, nameSearch)
        For i As Integer = 0 To listKhachSan.Count - 1
            Dim ks As KhachSan = listKhachSan(i)
            Dim urlImage As String = String.Format("http://www.khachsan24gio.vn{0}", ks.IMG_URL)
            Dim item As String = ""
            Dim urlDetail As String = String.Format("DetailKhachSan.aspx?IDKS={0}", ks.ID)
            item = String.Format("{0} <div style ='padding :10px;'> <div style ='float: left; padding-right: 10px;'> ", item)
            item = String.Format("{0} <a style ='text-decoration:none; width: 80px; height: 80px; display: block'  data-ajax='false' href ='{1}' > ", item, urlDetail)
            item = String.Format("{0} <img width='80' height='80' alt='{1}' src='{2}' /> </a></div> ", item, ks.NAME, urlImage)
            item = String.Format("{0}  <div style =' color: #6B6B6B;font-size: 0.8em;'><div style ='color: #097AC8; font-size: 1.1em; font-weight: bold;'> ", item)
            'item = String.Format("{0}             <rewrites>  <add name= 'rewrite' virtualUrl= '^~/kien-thuc-seo/rewrite-url-asp-net.html' rewriteUrlParameter=  'ExcludeFromClientQueryString' destinationUrl= '~/product.aspx?cate_id=1&product_id=10' ignoreCase= 'true'/> </rewrites>")
            item = String.Format("{0} <a class=""ui-link"" data-ajax='false'  style='text-decoration:none;' href='{1}' > {2}</a> </div> ", item, urlDetail, ks.NAME)
            Dim strGia As String = ""
            If ks.HIENTHIGIA = True AndAlso ks.GIA > 0 Then
                strGia = Format(ks.GIA, "#,###")
            Else
                strGia = String.Format("<a class=""ui-link"" data-ajax='false' style=""text-decoration:none;"" href=""GetPrice.aspx?IDKS={0}"">Click lấy giá</a>", ks.ID)
            End If
            item = String.Format("{0} <div style ='color: #FFA500; float: right; font-size: 1.1em; font-weight: bold;'>{1}  </div>", item, strGia)
            Dim strStart As String = String.Format("Images/star-yellow-{0}-0.png", ks.STARS)

            item = String.Format("{0}  <div style =''><img  src='{1}'> </div> <div style =''> <img style='float: left;padding-right: 5px;' src='Images/hand.png' alt=''>", item, strStart)
            item = String.Format("{0} <div style ='padding-top: 2px;'>{1} đánh giá</div></div></div>", item, ks.COUNTDANHGIA)
            item = String.Format("{0} <div style ='clear :both ;'></div></div>", item)
            item = String.Format("{0} <div style ='background: none repeat scroll 0 0 #D1D1D1; height: 2px;'></div>", item)

            ''String.Format("<div style ='padding:10px;'><div id='{0}' style='cursor:pointer;' onclick='SelectedKhachSan(this)'>Khách sạn {1}</div></div>", listKhachSan(i).ID, listKhachSan(i).NAME)

            result += item
        Next
        Dim list As List(Of String) = New List(Of String)
        list.Add(result)
        If Util.GetConfigKey("page_num") * (page + 1) > nCountAll Or Util.GetConfigKey("page_num") * (page + 1) = nCountAll Then
            list.Add("1")
        Else
            list.Add("0")
        End If
        Return list
    End Function
    <WebMethod()> _
    <ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
    Public Shared Function LoadContinuesListArticles(ByVal page As Integer) As List(Of String)
        Dim result As String = ""
        Dim nCountAll As Integer = TinhThanhServer.GetCountTinDuLich()

        Dim listTinTuc As List(Of Dictionary(Of String, Object)) = TinhThanhServer.GetListTinDuLich(page)
        For i As Integer = 0 To listTinTuc.Count - 1
            If Not Util.GetDictionaryValueByKey(listTinTuc(i), "PDesc").Equals("") Then
                Dim url As String = Util.GetConfigKey("RootURl") + Util.GetDictionaryValueByKey(listTinTuc(i), "PLink")
                result &= " <li class=""liArticleItem ui-btn ui-btn-icon-right ui-li-has-arrow ui-li ui-last-child ui-btn-up-c"" data-corners=""false"" data-shadow=""false"" data-iconshadow=""true"" data-wrapperels=""div"" data-icon=""arrow-r"" data-iconpos=""right"" data-theme=""c"">"
                result &= "<div class=""ui-btn-inner ui-li""><div class=""ui-btn-text""><a class=""ui-link-inherit"" href='" + url + "' "
                result &= " Title = '" + Util.GetDictionaryValueByKey(listTinTuc(i), "PTitle") + "'> <span"
                result &= " class='thumb'>"
                result &= " <img title='" + Util.GetDictionaryValueByKey(listTinTuc(i), "PTitle") + "'"
                result &= " src='" + Util.GetDictionaryValueByKey(listTinTuc(i), "PImg") + "' width='80px' height='80px' /></span> <span class='heading'>"
                result &= Util.GetDictionaryValueByKey(listTinTuc(i), "PTitle") + "</span> <span class='desc'>"
                result &= Util.GetDictionaryValueByKey(listTinTuc(i), "PDesc") + "...</span>"
                result &= " </a></div><span class=""ui-icon ui-icon-arrow-r ui-icon-shadow""> </span></div></li>"
            End If
        Next
        Dim list As List(Of String) = New List(Of String)
        list.Add(result)
        If Util.GetConfigKey("page_num") * (page + 1) > nCountAll Or Util.GetConfigKey("page_num") * (page + 1) = nCountAll Then
            list.Add("1")
        Else
            list.Add("0")
        End If
        Return list
    End Function
    <WebMethod()> _
    <ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
    Public Shared Function LoadContinuesListAssess(ByVal page As Integer, ByVal id As String) As List(Of String)
        Dim result As String = ""
        Dim idKS As New Guid(id)
        Dim nCountAll As Integer = DatPhongServer.GetCountDanhGiaByIDHotel(idKS)
        Dim listDanhGia As List(Of DanhGia) = DatPhongServer.GetListDanhGiaByIDHotel(idKS, page)
        Dim ncountDG As Integer = DatPhongServer.GetCountDanhGiaByIDHotel(idKS)
        For i As Integer = 0 To listDanhGia.Count - 1
            Dim strHTML As String = ""
            strHTML &= " <div class='bottom-20 rc-item' style='border-top: 1px solid #ccc; padding-top: 20px;'>"
            strHTML &= " <div class='bottom-5'><b>" + listDanhGia(i).TIEU_DE + "</b></div>"
            strHTML &= " <div class='bottom-5 gray small'>"
            Dim strDate As String = String.Format("{0}/{1}/{2}", listDanhGia(i).CREATED_DATE.Day, listDanhGia(i).CREATED_DATE.Month, listDanhGia(i).CREATED_DATE.Year)
            strHTML = String.Format(" {0} Đánh giá <b>{1}</b>/10 bởi {2} ngày {3} </div>", strHTML, listDanhGia(i).RATE, listDanhGia(i).FULL_NAME, strDate)
            strHTML &= " <div class='bottom-5'>" + listDanhGia(i).CONTENT + "</div> </div><div class='clear' style='height:10px;'></div>"

            result = result + strHTML
        Next
        Dim list As List(Of String) = New List(Of String)
        list.Add(result)
        If Util.GetConfigKey("page_num") * (page + 1) > nCountAll Or Util.GetConfigKey("page_num") * (page + 1) = nCountAll Then
            list.Add("1")
        Else
            list.Add("0")
        End If
        Return list
    End Function
    <WebMethod()> _
<ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
    Public Shared Function LoadDetailLoaiPhong(ByVal id_KS As String, ByVal id_LoaiPhong As String) As String
        Dim strViewTTLP As String = ""
        Dim idKS As New Guid(id_KS)
        Dim idLoai As New Guid(id_LoaiPhong)
        Dim khachSan As KhachSan = KhachSanServer.GetLoaiHotelByIdHotelAndIDLoai(idKS, idLoai)
        strViewTTLP &= "<div class='a12' style='padding:7px 0 0;'>Thông tin phòng<b> &nbsp;" + khachSan.NAMELOAIPHONG + "</b></div>"
        'strViewTTLP &= " <img style='margin: 5px 0;max-width:400px;width:100%;' alt='Signature Superior' src='http://du-lich.Khachsan24gio.com/f/m/1310/17/khach-san-palace-sai-gon-8.jpg?w=400&c=1'>"
        strViewTTLP &= " <div class='content'><div class='qui-dinh-2'>"
        If khachSan.DESCRIPTIONLOAIPHONG.Equals("") Then
            strViewTTLP &= " <p>Phòng có diện tích khoảng " + khachSan.DIEN_TICH + ". " + khachSan.DESCRIPTIONLOAIPHONG + "</p></div><div class='qui-dinh-2'>"
            'strViewTTLP &= " <span>Phòng có bao gồm ăn sáng<br></span><span></span>"
            strViewTTLP &= " <span>Phòng dành cho " + khachSan.SO_NGUOI.ToString() + " người<br></span>"
            If khachSan.SO_GIUONG_DOI > 0 Then
                strViewTTLP &= " <span>Phòng có " + khachSan.SO_GIUONG_DOI.ToString() + " giường đôi<br></span>"
            End If
            If khachSan.SO_GIUONG_DON > 0 Then
                strViewTTLP &= " <span>Phòng có " + khachSan.SO_GIUONG_DON.ToString() + " giường đơn<br></span>"
            End If
            strViewTTLP &= " <span></span><span></span>"
        Else
            strViewTTLP &= " <p>" + khachSan.DESCRIPTIONLOAIPHONG + "</p>"
        End If
        strViewTTLP &= " </div><div class='qui-dinh-2'><br>"
        strViewTTLP &= " <div class='sub-sub-title'><b> Tiện nghi - Dịch vụ trong phòng</b></div>"
        strViewTTLP &= " <table id='repRoomTypeInfos_ctl02_dlRoomFacilities' cellspacing='0' cellpadding='5' border='0' style='border-collapse:collapse;'><tbody>"
        Dim arrDichVuTN As ArrayList = KhachSanServer.GetDichVuTienNghiByIDLoaiPhong(khachSan.ID, khachSan.IDLOAIPHONG)
        For i As Integer = 0 To arrDichVuTN.Count - 2 Step 2
            strViewTTLP &= " <tr> "
            strViewTTLP &= " <td><div class='bullet'> " + arrDichVuTN(i) + "</div></td>"
            strViewTTLP &= "<td><div class='bullet'> " + arrDichVuTN(i + 1) + "</div></td>"
            strViewTTLP &= "</tr>"
        Next
        strViewTTLP &= " </tbody></table></div>"
        strViewTTLP &= "</div>"
        Return strViewTTLP
    End Function

End Class
